import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './index.css'
import AnimationDirective from './directives/animation'
import { vParallax } from './directives/parallax'

// 引入 Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

const app = createApp(App)
app.use(router)
app.use(AnimationDirective)
app.use(ElementPlus, {
  locale: zhCn,
})
app.directive('parallax', vParallax)
app.mount('#app')

// 注册 Service Worker
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js')
      .then(registration => {
        console.log('SW registered:', registration);
      })
      .catch(error => {
        console.log('SW registration failed:', error);
      });
  });
}